export default {
  template: `
    <div>
    <label for="username">用户名</label>
    <input type="text" name="username" v-model="username" placeholder="用户名">
    <label for="password">密码</label>
    <input type="password" name="password" v-model="password" placeholder="密码">
    <button @click="handleSubmit">登录</button>
    <button @click="handleUserInfo">获取用户的信息</button>
  </div>
    `,
    data:function(){
        return {
            username:"user",
            password:"user"
        }
    },
    methods:{
        handleSubmit:function(){
            axios.post("/login",{
                username:this.username,
                password:this.password
            }).then(res=>{
                console.log(res.data);
                if(res.data.code === 1){
                    this.$router.push("dashboard");
                }

            })
        },
        handleUserInfo:function(){
            axios.get("/users").then(res=>{
                console.log(res)
            })
        }
    }
};
